<?php

require_once '../Common/values.php';
require_once '../Helpdesk/theme.php';
require_once '../Common/database.php';
$userfolders='%'.$user.'%';
echo '<head><title>Vospers knowledge base</title></head><SCRIPT LANGUAGE="JavaScript" TYPE="text/JavaScript">

function display(active)
{
if(active.style.display==\'block\')
    {
     active.style.display=\'none\';
    }
else
    {

    active.style.display=\'block\';

    }
}
</SCRIPT>';
echo '<center><h3>Vospers knowledge base</h3>';
echo 'Search : <FORM action="publicsearch.php" method="POST"><input type="text" name="search"><input type="submit" value="Go"></FORM>';
echo '<p><table width="1000px" height="450px"><tr><td valign="top" width="15%">';
echo'<table>';
$result = mysql_query("SELECT * FROM tblkbfolders WHERE Users = 'all' Order By `Folder`");
while($row = mysql_fetch_array($result))
{
echo '<tr><td class="noborder" onclick="display(folder'.$row[ID].');"><img src="../img/folder.gif"> '.$row[Folder].'</td></tr>';

$result1 = mysql_query("SELECT * FROM tblkb WHERE Folder ='$row[Folder]' AND Users='all' Order By `Name`");
echo '<tr><td class="noborder"><div style="display:none;" id="folder'.$row[ID].'">';
echo '<table>';
while($row1 = mysql_fetch_array($result1))
{

echo '<tr><td class="noborder" width="10px"></td><td class="noborder" onclick="location=\'public.php?p=kb&l='.$row1[lognumber].'\'"><img src="../img/sub_folder.gif"> '.$row1[Name].'</td></tr>';

}
#echo '<tr><td class="noborder"></td><td class="noborder" onclick="location=\'index.php?p=kbnew&f='.$row[Folder].'\'"><b>New</td></tr>';
echo '</table>';
echo '</div></td></tr>';
}
#echo '<tr><td class="noborder" onclick="location=\'index.php?p=shadd&f2=kbfolders\'"><b>New</td></tr>';
echo '</table>';
$result=mysql_query("SELECT * FROM tblkb WHERE lognumber='$_GET[l]' AND Users='all' Order By `Name`");
$row = mysql_fetch_array($result);
if($_GET[l]!='')
{
echo '<td valign="top"><center>
<table>
<tr><td class="noborder">KB number :</td><td class="noborder">'.$row[lognumber].'</td></tr>
<tr><td class="noborder">Subject : </td><td class="noborder">'.$row[Name].'</td></tr>';
echo '<tr><td class="noborder" colspan="2">Documents:
';
$result = mysql_query("SELECT * FROM tblkbdocuments WHERE LogNumber='$_GET[l]' AND Users='all' Order By `Document`");
echo '<table width="500px"><tr bgcolor="'.$colourtoprow.'"><td width="20px">Document number</td><td>Filename</td><td>Rev</td><td width="30px"></td><td width="30px"></td></tr>';
while($row = mysql_fetch_array($result))
{
echo '<tr><td>'.$row[DocNumber].'</td><td>';
if($row[Out]!='')
{
echo ''.$row[Document].'</td><td>'.$row[Rev].'</td><td><b>Out</td><td>In</td></tr>';
}
else
{
echo '<a href="documents/'.$row[Document].'">'.$row[Document].'</a></td><td width="20px">'.$row[Rev].'</td><td width="30px">Out</td><td width="30px"><b>In</td></tr>';

}
}
#echo'<tr><form method="Post" Action="index.php?p=kbupload&l='.$_GET[l].'" enctype="multipart/form-data"><td colspan="4"><input type="hidden" name="MAX_FILE_SIZE" value="1000000000">
#Choose a file to upload: <input type="hidden" name="lognumber"><input name="document" type="file"><input type="submit" value="Upload"></form></td></tr></table>
#</td></tr>
echo '</table>
</td></tr>';
}
else
{
 echo '<td valign="top">Click on the folder icons on the left hand side</td></tr>';
}
echo '</table></center></table>';

require_once "../Common/footer.php";
?>
